﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ibba.agil.core.common;
using ibba.agil.core;

namespace ibba.agil.data
{

    public class tbagi017IpiCamoKey : IDataKey
    {
        public string IndicadorDominioCorporativo { get; set; }
        public int IdentificadorCarteira { get; set; }
    }

    public class tbagi017IpiCamo_COL : CollectionData<tbagi017IpiCamoKey, tbagi017IpiCamo_ENT>
    {

        private manager.tbagi017IpiCamo_COM _manager;
        private Criteria<CriteriaInfo, object> _pesquisa;
        private int _idCarteira;
        private string _dominio;

        public tbagi017IpiCamo_COL()
        {
            _manager = new manager.tbagi017IpiCamo_COM();
        }

        protected override Criteria<CriteriaInfo, object> CriteriaFind()
        {
            _pesquisa = new Criteria<CriteriaInfo, object>(new tbagi017IpiCamo_ENT());
            if (!String.IsNullOrEmpty(_dominio))
            {
                _pesquisa.Add(new CriteriaInfo()
                {
                    LikePattern = LikePattern.Both,
                    LogicalType = LogicalOperator.AND,
                    NameProperty = "TextoNomeDominio",
                    SearchType = LogicalComparator.EQUAL
                }, _dominio);
            }
            return _pesquisa;
        }

        public override List<tbagi017IpiCamo_ENT> Find(tbagi017IpiCamoKey objectKey)
        {
            _idCarteira = objectKey.IdentificadorCarteira;
            _dominio = objectKey.IndicadorDominioCorporativo;
            return _manager.Where(CriteriaFind);
        }
    }
}
